<template>
  <div class="pagination-container">
    <t-pagination
      v-model="currentPage"
      :total="total"
      :page-size.sync="pageSize"
      show-sizer
      show-jumper
      :page-size-options="pageSizes"
      :on-page-size-change="handleSizeChange"
      @current-change="handleCurrentChange"
    />
  </div>
</template>

<script>
export default {
  name: "Pagination",
  props: {
    total: {
      required: true,
      type: Number
    },
    page: {
      type: Number,
      default: 1
    },
    limit: {
      type: Number,
      default: 10
    },
    pageSizes: {
      type: Array,
      default() {
        return [10, 15, 25, 50];
      }
    }
  },
  data() {
    return {
      // globalConfig: {
      //   pagination: {
      //     itemsPerPage: "{size} / page",
      //     jumpTo: "",
      //     page: "Page",
      //     total: "{total} total"
      //   }
      // }
    };
  },
  computed: {
    currentPage: {
      get() {
        return this.page;
      },
      set(val) {
        this.$emit("update:page", val);
      }
    },
    pageSize: {
      get() {
        return this.limit;
      },
      set(val) {
        this.$emit("update:limit", val);
      }
    }
  },
  methods: {
    handleSizeChange(val) {
      this.$emit("pagination", { page: this.currentPage, limit: val });
    },
    handleCurrentChange(val) {
      this.$emit("pagination", { page: val, limit: this.pageSize });
    }
  }
};
</script>

<style lang="scss" scoped>
.pagination-container{
  margin: 20px 0;
  height: 50px;
  background: #fff !important;
}
::v-deep .t-input-number--normal .t-input__inner {
  text-align: center;
  color: #00000066;
}
::v-deep .t-pagination__total {
  font-family: PingFangSC-Regular, PingFang SC;
  font-weight: 400;
  color: #5b6169;
}
::v-deep .t-select .t-select__single {
  font-weight: 400;
  color: #212831;
}
::v-deep .t-pagination__number:active{
  background: #fff;
   color: #212831;
}
</style>
